package mock.servicesdirectory.organisations.web.action;

import java.util.List;

import mock.servicesdirectory.common.entities.Directorate;
import mock.servicesdirectory.common.entities.Team;
import mock.servicesdirectory.organisations.business.businessinterface.TeamBO;

import com.opensymphony.xwork2.ActionSupport;

public class TeamAction extends ActionSupport{
	
	private TeamBO teamBO;
	
	private List<Team> gridModel;	
	private Integer rows = 0;	
	private Integer page = 0;	
	private String sord;	
	private String sidx;
	private String searchField;
	private String searchString;
	private String searchOper;	
	private Integer total = 0;
	private Integer records = 0;
	
	private String teamName;
	private String typeBussiness;
	private String shortDescription;
	private int sicCode;
	private String leadContact;
	private boolean copyOrganisation;
	private String teamDescription;
	private String addressLine1;
	private String addressLine2;
	private String addressLine3;
	private int phoneNumber;
	private int fax;
	private String email;
	private int postCode;
	private String webAddress;
	private String townVillage;
	private String county;
	private String nation;
	
	public Integer getRows() {
		return rows;
	}
	public void setRows(Integer rows) {
		this.rows = rows;
	}
	public Integer getRecords() {
		return records;
	}
	public void setRecords(Integer records) {
		this.records = records;
	}
	public String getTeamName() {
		return teamName;
	}
	public void setTeamName(String teamName) {
		this.teamName = teamName;
	}
	public String getTypeBussiness() {
		return typeBussiness;
	}
	
	public String getTeamDescription() {
		return teamDescription;
	}
	public void setTeamDescription(String teamDescription) {
		this.teamDescription = teamDescription;
	}
	public void setTypeBussiness(String typeBussiness) {
		this.typeBussiness = typeBussiness;
	}
	public String getShortDescription() {
		return shortDescription;
	}
	public void setShortDescription(String shortDescription) {
		this.shortDescription = shortDescription;
	}
	public int getSicCode() {
		return sicCode;
	}
	public void setSicCode(int sicCode) {
		this.sicCode = sicCode;
	}
	public String getLeadContact() {
		return leadContact;
	}
	public void setLeadContact(String leadContact) {
		this.leadContact = leadContact;
	}
	public boolean isCopyOrganisation() {
		return copyOrganisation;
	}
	public void setCopyOrganisation(boolean copyOrganisation) {
		this.copyOrganisation = copyOrganisation;
	}
	public String getAddressLine1() {
		return addressLine1;
	}
	public void setAddressLine1(String addressLine1) {
		this.addressLine1 = addressLine1;
	}
	public String getAddressLine2() {
		return addressLine2;
	}
	public void setAddressLine2(String addressLine2) {
		this.addressLine2 = addressLine2;
	}
	public String getAddressLine3() {
		return addressLine3;
	}
	public void setAddressLine3(String addressLine3) {
		this.addressLine3 = addressLine3;
	}
	public int getPhoneNumber() {
		return phoneNumber;
	}
	public void setPhoneNumber(int phoneNumber) {
		this.phoneNumber = phoneNumber;
	}
	public int getFax() {
		return fax;
	}
	public void setFax(int fax) {
		this.fax = fax;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public int getPostCode() {
		return postCode;
	}
	public void setPostCode(int postCode) {
		this.postCode = postCode;
	}
	public String getWebAddress() {
		return webAddress;
	}
	public void setWebAddress(String webAddress) {
		this.webAddress = webAddress;
	}
	public String getTownVillage() {
		return townVillage;
	}
	public void setTownVillage(String townVillage) {
		this.townVillage = townVillage;
	}
	public String getCounty() {
		return county;
	}
	public void setCounty(String country) {
		this.county = country;
	}
	public String getNation() {
		return nation;
	}
	public void setNation(String nation) {
		this.nation = nation;
	}
	public TeamBO getTeamBO() {
		return teamBO;
	}
	public void setTeamBO(TeamBO teamBO) {
		this.teamBO = teamBO;
	}
	
	public String save(){
		Team temp = new Team();
		temp.setTeamName(teamName);
		if(! teamBO.checkExistTeam(teamName)){
		temp.setStatus(true);
		temp.setAddressLine1(addressLine1);
		temp.setAddressLine2(addressLine2);
		temp.setAddressLine3(addressLine3);
		temp.setCityTown(townVillage);
		temp.setContactId(Integer.parseInt(leadContact));
		temp.setCounty(county);
		temp.setDepartmentId(1);
		temp.setEmail(email);
		temp.setWeb(webAddress);
		temp.setFax(Integer.toString(fax));
		temp.setPhone(Integer.toString(phoneNumber));
		temp.setPostCode(postCode);
		temp.setTeamName(teamName);
		temp.setTeamShortDesc(shortDescription);
		temp.setTeamFullDesc(teamDescription);
		temp.setDepartmentId(1);
		temp.setCountryId(12);
		
		teamBO.addTeam(temp);
		}
		return SUCCESS;
	}
	public String back(){
		return SUCCESS;
	}
	public String creat(){
		return SUCCESS;
	}
	

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		this.total = total;
	}

	public String getSearchOper() {
		return searchOper;
	}

	public void setSearchOper(String searchOper) {
		this.searchOper = searchOper;
	}

	public String getSearchString() {
		return searchString;
	}

	public void setSearchString(String searchString) {
		this.searchString = searchString;
	}

	public String getSearchField() {
		return searchField;
	}

	public void setSearchField(String searchField) {
		this.searchField = searchField;
	}

	public String getSidx() {
		return sidx;
	}

	public void setSidx(String sidx) {
		this.sidx = sidx;
	}

	public String getSord() {
		return sord;
	}

	public void setSord(String sord) {
		this.sord = sord;
	}

	public List<Team> getGridModel() {
		return gridModel;
	}

	public void setGridModel(List<Team> list) {
		this.gridModel = list;
	}

	public String execute() {		
		records = 30;
		rows = 10;
		
		setGridModel(teamBO.getTeam());
		setTotal((int) Math.ceil((double) records / (double) rows));

		return SUCCESS;
	}

	// Method to filter all Team
	public String filterAll(){
		// Call methods to get all database of Team via TeamBOImpl.getTeam()
		return SUCCESS;
	}
	
	// Method to filter Team start with 0-9
	public String filter09(){
		// Call methos to get database of Team where name start with a digit 0-9 via TeamBOImpl.getTeam(1)
		return SUCCESS;
	}
	
	// Method to filter Team start with ABCDE
	public String filterAE(){
		// Call methos to get database of Team where name start with a digit 0-9 via TeamBOImpl.getTeam(2)
		
		return SUCCESS;
	}
	
	// Method to filter Team start with FGHIJ
	public String filterFJ(){
		// Call methos to get database of Team where name start with a digit 0-9 via TeamBOImpl.getTeam(3)
		
		return SUCCESS;
	}
	
	// Method to filter Team start with KLMN
	public String filterKN(){
		// Call methos to get database of Team where name start with a digit 0-9 via TeamBOImpl.getTeam(4)
		
		return SUCCESS;
	}
	
	// Method to filter Team start with OPQR
	public String filterOR(){
		// Call methos to get database of Team where name start with a digit 0-9 via TeamBOImpl.getTeam(5)
		
		return SUCCESS;
		
	}
	
	// Method to filter Team start with STUV
	public String filterSV(){
		// Call methos to get database of Team where name start with a digit 0-9 via TeamBOImpl.getTeam(6)
		
		return SUCCESS;
	}
	
	// Method to filter Team start with STUV
	public String filterWZ(){
		// Call methos to get database of Team where name start with a digit 0-9 via TeamBOImpl.getTeam()
		
		return SUCCESS;
	}
}
